﻿@model Models.UserModels.ProjectInfo

<div>
    <span class="pull-right">
        负责人
        @foreach (var item in Model.ProjectUsers.Where(a => a.Leader).Select(a => a.SysUser))
        {
            @Html.Partial("SysUserDisplay", item)
        }
        <span>&nbsp;</span>
        @Ajax.ActionLink(lang.Back, "Index", new { pageIndex = Request["pageIndex"] }, new AjaxOptions { UpdateTargetId = "Main" }, new { @class = "btn" })
        @if (Model.ProjectUsers.Any(a => a.SysUserId == ViewBag.UserId && a.Leader) && Model.LastProjectInfoId == null)
        {
            <span>&nbsp;</span>
            @Ajax.ActionLink("创建子项目", "Create", new { LastProjectInfoId = Model.Id }, new AjaxOptions { UpdateTargetId = "Main" }, new { @class = "btn" })
        }
        <span>&nbsp;</span>
        <a data-trigger="modal" data-title="新任务" class="btn" href="@Url.Action("Create", "MyProjectTask", new { SelectdProjectInfoId = Model.Id })">发布任务</a>
        <span>&nbsp;</span>
        @Ajax.ActionLink(lang.Refresh, "Details", new { id = Model.Id, pageIndex = Request["pageIndex"] }, new AjaxOptions { UpdateTargetId = "Main" }, new { @class = "btn" })
        <span>&nbsp;</span>
        @Ajax.ActionLink(lang.Edit, "Edit", new { id = Model.Id }, new AjaxOptions { UpdateTargetId = "Main" }, new { @class = "btn" })
        <span>&nbsp;</span>
        @Ajax.ActionLink(lang.Delete, "Delete", null, new { id = Model.Id, table = "ProjectInfo" }, new AjaxOptions { UpdateTargetId = "Main", HttpMethod = "Delete", Confirm = "您确定要删除该记录吗？该操作不可恢复！" }, new { @class = "btn" })
    </span>
    <blockquote>
        <h3>
            @if (Model.LastProjectInfo != null)
            {
                if (!Model.LastProjectInfo.Public)
                {
                    <i class="icon-lock"></i>
                }
                @Ajax.ActionLink(Model.LastProjectInfo.ProjectName, "Details", new { Model.LastProjectInfo.Id }, new AjaxOptions { UpdateTargetId = "Main" }, new { })

                <span>@(Model.LastProjectInfo.Finish ? "(" + lang.Finish + ")" : "")</span>

                <i class="icon-chevron-right"></i>
            }

            @if (!Model.Public)
            {
                <i class="fa fa-lock"></i>
            }
            @Html.DisplayFor(a => a.ProjectInfoState.ProjectInfoStateName)
            @Html.DisplayFor(a => a.ProjectName)

            <span>@(Model.Finish ? "(" + lang.Finish + ")" : "")</span>
        </h3>
        @if (!string.IsNullOrEmpty(Model.Tag))
        {
            <ul class="list-inline">
                <li><i class="fa fa-tags"></i></li>
                @foreach (var keyword in Model.Tag.Split(' '))
                {
                    <li>
                        @Ajax.ActionLink(" " + keyword, "Index", new { keyword = keyword }, new AjaxOptions { UpdateTargetId = "Main" }, new { })
                    </li>
                }
            </ul>
        }

        <hr />

        @if (Model.ProjectInfos.Any())
        {
            <ul class="list-inline">
                <li>子项目:</li>
                @foreach (var item in Model.ProjectInfos)
                {
                    <li>
                        @if (!item.Public)
                        {
                            <i class="fa fa-lock"></i>
                        }
                        @Ajax.ActionLink(item.ProjectName, "Details", new { item.Id }, new AjaxOptions { UpdateTargetId = "Main" }, new { })
                        <span>@(item.Finish ? "(" + lang.Finish + ")" : "")</span>
                    </li>
                }
            </ul>
            <hr />
        }

        <div>@Html.DisplayFor(modelItem => Model.ProjectObjective)</div>
        <hr />
        <div>
            @Html.DisplayFor(modelItem => Model.Raty)
            @Html.DisplayFor(modelItem => Model.StarTime)
            @if (Model.EndTime.HasValue)
            {
                <span>~</span>
                @Html.DisplayFor(modelItem => Model.EndTime)
                <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                <span class="lead">
                    剩余<span class="text-info">
                        @(new TimeSpan(Model.EndTime.Value.Date.AddDays(1).AddSeconds(-1).Ticks - DateTime.Now.Ticks).TotalDays.ToString("0.0"))
                    </span>天
                </span>
            }
            <span>耗时 @(Model.Plans.Where(a => !a.Deleted).Sum(a => (a.EndDate - a.StartDate).TotalDays).ToString("0.0")) 天</span>
        </div>
    </blockquote><hr />
</div>

<div>
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab4" data-toggle="tab">人员 @Model.ProjectUsers.Count</a></li>
        <li><a href="#tab5" data-toggle="tab">客户信息</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab4">
            <fieldset>
                <legend>项目成员 <small>（@Model.ProjectUsers.Count(a => !a.Follow) 人）</small></legend>
                @foreach (var item in Model.ProjectUsers.Where(a => !a.Follow).OrderByDescending(a => a.Leader))
                {
                    <div class="media pull-left" style="margin: 10px;">
                        <a class="pull-left" href="javascript:;">
                            @if (!string.IsNullOrEmpty(item.SysUser.Picture))
                            {
                                <img src="@item.SysUser.Picture" class="img-rounded" style="width: 50px; height: 50px;" />
                            }
                            else
                            {
                                <img src="~/Content/default_man_middle.jpg" class="img-rounded" style="width: 50px; height: 50px;" />
                            }
                        </a>
                        <div class="media-body">
                            <div class="media-heading">@Html.Partial("SysUserDisplay", item.SysUser)</div>
                            @if (item.Leader)
                            {
                                <small>（负责人）</small>
                            }
                        </div>
                    </div>
                }
            </fieldset>
            <hr />
            <div class="clearfix"></div>
            <fieldset>
                <legend>项目关注者 <small>（@Model.ProjectUsers.Count(a => a.Follow) 人）</small></legend>
                @foreach (var item in Model.ProjectUsers.Where(a => a.Follow))
                {
                    <div class="media pull-left" style="margin: 10px;">
                        <a class="pull-left" href="javascript:;">
                            @if (!string.IsNullOrEmpty(item.SysUser.Picture))
                            {
                                <img src="@item.SysUser.Picture" class="img-rounded" style="width: 50px; height: 50px;" />
                            }
                            else
                            {
                                <img src="~/Content/default_man_middle.jpg" class="img-rounded" style="width: 50px; height: 50px;" />
                            }
                        </a>
                        <div class="media-body">
                            <div class="media-heading">@Html.Partial("SysUserDisplay", item.SysUser)</div>
                        </div>
                    </div>
                }
            </fieldset>
        </div>
        <div class="tab-pane" id="tab5">
            @Html.DisplayFor(a => a.Customer)
        </div>
    </div>
</div>
